﻿(function ($) {
    $.fn.fakeLoader = function (d) {
        var e = $.extend({
            timeToHide: 1200,
            pos: 'absolute',
            top: '0px',
            left: '0px',
            zIndex: '999',
            spinner: 'spinner6',
            imagePath: ''
        },
        d);
        var f = '<div class="fl spinner1"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>';
        var g = '<div class="fl spinner2"><div class="spinner-container container1"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container2"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container3"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div></div>';
        var h = '<div class="fl spinner3"><div class="dot1"></div><div class="dot2"></div></div>';
        var i = '<div class="fl spinner4"></div>';
        var j = '<div class="fl spinner5"><div class="cube1"></div><div class="cube2"></div></div>';
        var k = '<div class="fl spinner6"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>';
        var l = '<div class="fl spinner7"><div class="circ1"></div><div class="circ2"></div><div class="circ3"></div><div class="circ4"></div></div>';
        var m = $(this);
        var n = {
            'position': e.pos,
            'width': e.width,
            'height': e.height,
            'top': e.top,
            'left': e.left
        };
        m.css(n);
        m.each(function () {
            var a = e.spinner;
            switch (a) {
                case 'spinner1':
                    m.html(f);
                    break;
                case 'spinner2':
                    m.html(g);
                    break;
                case 'spinner3':
                    m.html(h);
                    break;
                case 'spinner4':
                    m.html(i);
                    break;
                case 'spinner5':
                    m.html(j);
                    break;
                case 'spinner6':
                    m.html(k);
                    break;
                case 'spinner7':
                    m.html(l);
                    break;
                default:
                    m.html(f)
            }
            if (e.imagePath != '') {
                m.html('<div class="fl"><img src="' + e.imagePath + '"></div>');
                centerLoader()
            }
        });
        setTimeout(function () {
            $(m).fadeOut();
            var a = navigator.userAgent;
            var b = a.indexOf('Android') > -1 || a.indexOf('Adr') > -1;
            var c = !!a.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
            if (b == true) {
                $("#b").html('<p style="padding: 12px;color: #3AB2A7;">正在安装，请耐心等待</p>')
            } else if (c == true) {
                $("#b").html('<p style="padding: 12px;color: #3AB2A7;">安装中...按Home键找到APP<br>点击下面按钮查看启动方法</p>')
            } else {
                $("#b").html('<p style="padding: 12px;color: #3AB2A7;">正在安装，请耐心等待</p>')
            }
        },
        e.timeToHide);
        return this.css({
            'backgroundColor': e.bgColor,
            'zIndex': e.zIndex
        })
    };
    function centerLoader() {
        var a = $(window).width();
        var b = $(window).height();
        var c = $('.fl').outerWidth();
        var d = $('.fl').outerHeight();
        $('.fl').css({
            'position': 'absolute',
            'left': (a / 2) - (c / 2),
            'top': (b / 2) - (d / 2)
        })
    }
    $(window).load(function () {
        centerLoader();
        $(window).resize(function () {
            centerLoader()
        })
    });
    $.fn.fakeLoaders = function (b) {
        var c = $.extend({
            timeToHide: 1200,
            pos: 'absolute',
            top: '0px',
            left: '0px',
            zIndex: '999',
            spinner: 'spinner6',
            imagePath: ''
        },
        b);
        var d = '<div class="fl spinner1"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>';
        var e = '<div class="fl spinner2"><div class="spinner-container container1"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container2"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container3"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div></div>';
        var f = '<div class="fl spinner3"><div class="dot1"></div><div class="dot2"></div></div>';
        var g = '<div class="fl spinner4"></div>';
        var h = '<div class="fl spinner5"><div class="cube1"></div><div class="cube2"></div></div>';
        var i = '<div class="fl spinner6"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>';
        var j = '<div class="fl spinner7"><div class="circ1"></div><div class="circ2"></div><div class="circ3"></div><div class="circ4"></div></div>';
        var k = $(this);
        var l = {
            'position': c.pos,
            'width': c.width,
            'height': c.height,
            'top': c.top,
            'left': c.left
        };
        k.css(l);
        k.each(function () {
            var a = c.spinner;
            switch (a) {
                case 'spinner1':
                    k.html(d);
                    break;
                case 'spinner2':
                    k.html(e);
                    break;
                case 'spinner3':
                    k.html(f);
                    break;
                case 'spinner4':
                    k.html(g);
                    break;
                case 'spinner5':
                    k.html(h);
                    break;
                case 'spinner6':
                    k.html(i);
                    break;
                case 'spinner7':
                    k.html(j);
                    break;
                default:
                    k.html(d)
            }
            if (c.imagePath != '') {
                k.html('<div class="fl"><img src="' + c.imagePath + '"></div>');
                centerLoader()
            }
        });
        setTimeout(function () {
            $(k).fadeOut();
            $("#da").html('<p style="padding: 12px;color: #3AB2A7;">安装中...按Home键找到APP<br>点击下面按钮查看启动方法</p>')
        },
        c.timeToHide);
        return this.css({
            'backgroundColor': c.bgColor,
            'zIndex': c.zIndex
        })
    }
}(jQuery));